package com.tedu.api.d5_io_seri;

import java.io.Serializable;

/** 本类用于封装学生类
 *
 *  如果本类想要完成序列化，必须实现序列化接口
 *                      implements Serializable
 *   Serializable 空-接口,
 *   作用：作为标志，标志这个类可以被 序列化/反序列化;
 * 否则报错：java.io.NotSerializableException
 * */
public class Student implements Serializable {

    private static final long serialVersionUID = -8130951680175609228L;
    private String name;
    private int age;
    private String gender;//性别
    private String address;

    /*
     创建无参，全参构造函数
     */
    public Student() {
        System.out.println("Student无参构造");
    }

    public Student(String name, int age, String gender, String address) {
        System.out.println("Student全参构造");
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.address = address;
    }
    /*
     提供get() set() 方法
     */
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", address='" + address + '\'' +
                '}';
    }
}
